import { ModalProps } from "@/components";
import { RenderFormItems } from "@/components/SearchForm/partials/RenderFormItem";
import { Form, Modal } from "antd";
import { getModalFields } from "./helper";

interface BatchModal extends ModalProps {
  rowKeys: any[];
}
export const BatchModal = ({
  onCancel: _onCancel,
  onOk: _onOk,
  ...restProps
}: BatchModal) => {
  const [form] = Form.useForm();
  const onOk = async () => {
    const formData = await form.validateFields();
    await _onOk(formData)
    onCancel()
  }
  const onCancel = () => {
    _onCancel?.();
    form.resetFields();
  };
  return (
    <Modal
      title="批量操作"
      /* width={800} */ onCancel={onCancel}
      onOk={onOk}
      {...restProps}
    >
      <Form form={form} labelCol={{ span: 6 }}>
        <RenderFormItems formConfigs={getModalFields()} />
      </Form>
    </Modal>
  );
};
